package Annotation.Test;

import Annotation.MyAnnotation;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test {
    static Map<Class,Method[]> map = new HashMap<>();
    public static void main(String[] args) throws Exception {
        Class clazz1 = Class.forName("Annotation.Test.Q");
        Class clazz2 = Class.forName("Annotation.Test.W");
        Class clazz3 = Class.forName("Annotation.Test.E");
        Class clazz4 = Class.forName("Annotation.Test.R");
        Class clazz5 = Class.forName("Annotation.Test.T");

        Method[] methods1 = clazz1.getDeclaredMethods();
        Method[] methods2 = clazz2.getDeclaredMethods();
        Method[] methods3 = clazz3.getDeclaredMethods();
        Method[] methods4 = clazz4.getDeclaredMethods();
        Method[] methods5 = clazz5.getDeclaredMethods();

        map.put(clazz1,methods1);
        map.put(clazz2,methods2);
        map.put(clazz3,methods3);
        map.put(clazz4,methods4);
        map.put(clazz5,methods5);

        Set<Class> set =map.keySet();
        for (Class clazz : set) {
            for (Method method : map.get(clazz)) {
                if(method.getAnnotation(MyAnnotation.class)!=null){
                    method.invoke(clazz.newInstance());
                }else {
                    System.out.println(method.getName()+"不能调用");
                }
            }
        }
    }
}
